package com.atguigu.service.impl;

import com.atguigu.dao.BaseDao;
import com.atguigu.dao.DictDao;
import com.atguigu.dao.HouseDao;
import com.atguigu.entity.House;
import com.atguigu.service.HouseService;
import com.atguigu.service.ipml.BaseServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

@DubboService
public class HouseServiceImpl extends BaseServiceImpl<House> implements HouseService {
    @Autowired
    private HouseDao houseDao;
    @Autowired
    private DictDao dictDao;
    @Override
    public BaseDao<House> getDao() {
        return houseDao;
    }

    @Override
    public void publish(Long houseId, Integer status) {
    houseDao.updateStatus(houseId,status);
    }

    @Override
    public House getById(Serializable id) {
        House house = houseDao.getById(id);
        house.setHouseTypeName(dictDao.getById(house.getHouseTypeId()).getName()); //户型
        house.setHouseUseName(dictDao.getById(house.getHouseUseId()).getName()); //用途
        house.setFloorName(dictDao.getById(house.getFloorId()).getName()); //楼层
        house.setDirectionName(dictDao.getById(house.getDirectionId()).getName()); //朝向
        house.setDecorationName(dictDao.getById(house.getDecorationId()).getName()); //装修情况
        house.setBuildStructureName(dictDao.getById(house.getBuildStructureId()).getName()); //建筑结构
        return house;
    }
}